package pl.perseus.dao;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import pl.perseus.model.Classes;
import pl.perseus.model.Student;

@Repository
public class StudentDao extends BaseDao<Student> implements IStudentDao{
 
	
	public StudentDao() {
		super("Student");
	}

	@Override
    public Student selectByIdStudent(Long id) {
    	Map<String, Object> map = new HashMap<String, Object>();
    	map.put("id", id);
        return queryForObject("getByIdStudent", map);
    }
	
	@Override
	public Student insertStudent(Student Student){
		return insertBean("insertStudent", Student);
	}
	
	@Override 
	public List<Student> getAllStudents(){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("active", true);
		return queryForList("getByActiveStudent", map);
	}
	
	@Override
	public List<Student> getStudentsInClasses(Classes classes){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("classesId", classes.getId());
		return queryForList("getStudentsInClasses", map);
	}
 
}
